﻿Public Class cFormasPago

    Private lDrFP As lbGlobalcom.dsCartera.CAR_FORMASPAGORow

    Sub New(ByVal IdFormaPago As String)
        Try
            Dim daFP As New dsCarteraTableAdapters.CAR_FORMASPAGOTableAdapter
            Dim dtFP As dsCartera.CAR_FORMASPAGODataTable = daFP.GetDataByIdFormaPago(IdFormaPago)
            If dtFP.Rows.Count > 0 Then
                lDrFP = dtFP.Rows(0)
            Else
                Throw New Exception("No existe forma de pago")
            End If
        Catch ex As Exception
            cError.SalvaError(ex, "Samuel")
            Throw ex
        End Try
    End Sub

    Public ReadOnly Property idFormaPago() As String
        Get
            Return lDrFP.IDFORMAPAGO
        End Get
    End Property

    Public ReadOnly Property Descripcion() As String
        Get
            Return lDrFP.DESCRIPCION
        End Get
    End Property

    Public ReadOnly Property NDias() As Int16
        Get
            Return lDrFP.NDIAS
        End Get
    End Property

    Public Function GetFechaVence(ByVal FechaActual As Date) As Date
        Return FechaActual.AddDays(lDrFP.NDIAS)
    End Function

    Protected Overrides Sub Finalize()
        lDrFP = Nothing
    End Sub
End Class

